package org.atlantis.datasink.utils;

public final class ToStringHelper {

	private StringBuilder content = new StringBuilder();

	private ToStringHelper(Class<?> type) {
		content.append(type.getName()).append(": {");
	}

	public static ToStringHelper create(Class<?> type) {
		return new ToStringHelper(type);
	}

	public ToStringHelper add(String name, Object value) {
		content.append("\"");
		content.append(name);
		content.append("\"");
		content.append(": ");
		content.append(value);
		content.append(", ");
		return this;
	}

	public ToStringHelper addValue(Object value) {
		content.append(value);
		content.append(", ");
		return this;
	}

	public String end() {
		int len = content.length();
		content.delete(len - 2, len);
		content.append("}");
		return content.toString();
	}
}
